import os
import requests
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
def generate_urls(data_type: str, start_date: str, end_date: str) -> list:
"""
Generate a list of URLs for flight lists, flight events, or measurements.
Args:
data_type (str): Type of data ("flight_list", "flight_events", "measurements").
start_date (str): The start date in the format YYYYMM or YYYYMMDD.
end_date (str): The end date in the format YYYYMM or YYYYMMDD.
Returns:
list: List of generated URLs.
"""
base_url = f"https://www.eurocontrol.int/performance/data/download/OPDI/v002/{data_type}/{data_type}_"
urls = []
if data_type == "flight_list":
start_dt = datetime.strptime(start_date, "%Y%m")
end_dt = datetime.strptime(end_date, "%Y%m")
delta = relativedelta(months=1)
current_dt = start_dt
while current_dt <= end_dt:
url = f"{base_url}{current_dt.strftime('%Y%m')}.parquet"
urls.append(url)
current_dt += delta
return urls
def download_files(urls: list, save_folder: str):
"""
Download files from the generated URLs and save them in the specified folder.
Args:
urls (list): List of URLs to download.
save_folder (str): Folder to save downloaded files.
"""
os.makedirs(save_folder, exist_ok=True)
for url in urls:
file_name = url.split("/")[-1]
save_path = os.path.join(save_folder, file_name)
if os.path.exists(save_path):
print(f"Skipping {file_name}, already exists.")
continue
print(f"Downloading {url}...")
try:
response = requests.get(url, stream=True)
response.raise_for_status()
with open(save_path, "wb") as file:
for chunk in response.iter_content(chunk_size=1024):
file.write(chunk)
print(f"Saved to {save_path}")
except requests.exceptions.RequestException as e:
print(f"Failed to download {url}: {e}")
if __name__ == "__main__":
datasets = {
"flight_list": ("`r format(start_date, "%Y%m")`", "`r format(end_date, "%Y%m")`")
}
for data_type, (start_date, end_date) in datasets.items():
urls = generate_urls(data_type, start_date, end_date)
download_files(urls, f"./data/{data_type}")Download Flight List v0.0.2 Datasets
Coverage: January 2022 - April 2026 | Version: v0.0.2
Below you will find links to download flight list v0.0.2 data files from January 01, 2022 to April 30, 2026. Each file is in Parquet format, providing a highly efficient way to store and manage large datasets. The datasets are organized by month.
Automated Download
If you want to automate your downloads, you can generate the link for downloading using the following format where YYYYMM is the year and month of interest.
https://www.eurocontrol.int/performance/data/download/OPDI/v002/flight_list/flight_list_{YYYYMM}.parquet
library(httr)
library(lubridate)
library(fs)
generate_urls <- function(data_type, start_date, end_date) {
base_url <- paste0("https://www.eurocontrol.int/performance/data/download/OPDI/v002/", data_type, "/", data_type, "_")
urls <- c()
start_dt <- ymd(paste0(start_date, "01"))
end_dt <- ymd(paste0(end_date, "01"))
delta <- months(1)
current_dt <- start_dt
while (current_dt <= end_dt) {
url <- paste0(base_url, format(current_dt, "%Y%m"), ".parquet")
urls <- c(urls, url)
current_dt <- current_dt + delta
}
return(urls)
}
download_files <- function(urls, save_folder) {
if (!dir_exists(save_folder)) {
dir_create(save_folder)
}
for (url in urls) {
file_name <- basename(url)
save_path <- file.path(save_folder, file_name)
if (file_exists(save_path)) {
message("Skipping ", file_name, ", already exists.")
next
}
message("Downloading ", url, "...")
tryCatch({
response <- GET(url, write_disk(save_path, overwrite = TRUE))
if (http_error(response)) {
warning("Failed to download ", url, ": HTTP error ", status_code(response))
} else {
message("Saved to ", save_path)
}
}, error = function(e) {
warning("Failed to download ", url, ": ", e$message)
})
}
}
# Example usage
urls <- generate_urls("flight_list", "`r format(start_date, "%Y%m")`", "`r format(end_date, "%Y%m")`")
download_files(urls, "./data/flight_list")Download Available Datasets
Each dataset corresponds to a specific month and year, listed below for easy access.
- January 2022
Download flight_list_202201.parquet - February 2022
Download flight_list_202202.parquet - March 2022
Download flight_list_202203.parquet - April 2022
Download flight_list_202204.parquet - May 2022
Download flight_list_202205.parquet - June 2022
Download flight_list_202206.parquet - July 2022
Download flight_list_202207.parquet - August 2022
Download flight_list_202208.parquet - September 2022
Download flight_list_202209.parquet - October 2022
Download flight_list_202210.parquet - November 2022
Download flight_list_202211.parquet - December 2022
Download flight_list_202212.parquet - January 2023
Download flight_list_202301.parquet - February 2023
Download flight_list_202302.parquet - March 2023
Download flight_list_202303.parquet - April 2023
Download flight_list_202304.parquet - May 2023
Download flight_list_202305.parquet - June 2023
Download flight_list_202306.parquet - July 2023
Download flight_list_202307.parquet - August 2023
Download flight_list_202308.parquet - September 2023
Download flight_list_202309.parquet - October 2023
Download flight_list_202310.parquet - November 2023
Download flight_list_202311.parquet - December 2023
Download flight_list_202312.parquet - January 2024
Download flight_list_202401.parquet - February 2024
Download flight_list_202402.parquet - March 2024
Download flight_list_202403.parquet - April 2024
Download flight_list_202404.parquet - May 2024
Download flight_list_202405.parquet - June 2024
Download flight_list_202406.parquet - July 2024
Download flight_list_202407.parquet - August 2024
Download flight_list_202408.parquet - September 2024
Download flight_list_202409.parquet - October 2024
Download flight_list_202410.parquet - November 2024
Download flight_list_202411.parquet - December 2024
Download flight_list_202412.parquet - January 2025
Download flight_list_202501.parquet - February 2025
Download flight_list_202502.parquet - March 2025
Download flight_list_202503.parquet - April 2025
Download flight_list_202504.parquet - May 2025
Download flight_list_202505.parquet - June 2025
Download flight_list_202506.parquet - July 2025
Download flight_list_202507.parquet - August 2025
Download flight_list_202508.parquet - September 2025
Download flight_list_202509.parquet - October 2025
Download flight_list_202510.parquet - November 2025
Download flight_list_202511.parquet - December 2025
Download flight_list_202512.parquet - January 2026
Download flight_list_202601.parquet - February 2026
Download flight_list_202602.parquet - March 2026
Download flight_list_202603.parquet - April 2026
Download flight_list_202604.parquet
We hope you find these datasets useful for your analysis and research. If you have any questions or require further assistance, please contact us at [email protected].